import math
    
def method2(m):
    '''边的数量'''
    n = math.sqrt(m)
    n = math.floor(n)
    single_edge = n * 2
    if m >= n**2 + 1:
        single_edge += 1
    if m >= n**2 + 1 + n:
        single_edge += 1 
    r = 2 * m - single_edge
    return r

if __name__ == '__main__':
    m = int(input())
    r = method2(m)
    print(r * 2)
 